﻿/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 *
 * The Original Code is tyzoh.jp code.
 *
 * The Initial Developer of the Original Code is Kazutaka Kurihara.
 * Portions created by the Initial Developer are Copyright (C) 2007
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * ***** END LICENSE BLOCK ***** */
using System;

namespace Qurihara
{
	/// <summary>
	/// KotodamaBase の概要の説明です。
	/// </summary>
	public interface IKotodamaBase 
	{
//		System.Windows.Forms.Form Form
//		{
//			get;
//			set;
//		}
		System.Windows.Forms.Control Control
		{
			get;
			//set;
		}
		/*
		bool LockWindow
		{
			get;
			set;
		}
		*/
		Qurihara.Presentation Presentation
		{
			get;
			set;
		}

		Microsoft.Ink.InkCollector InkCollector
		{
			get;
			set;
		}

		Qurihara.FigureElementList SelectedElementList
		{
			get;
			set;
		}

        //ToolBarDock.ToolBarManager ToolBarManager
        //{
        //    get;
        //    set;
        //}
		Qurihara.QBasic.FocusManager FocusManager
		{
			get;
			set;
		}
		System.Collections.Hashtable EnvironmentTable
		{
			get;
			set;
		}

		event DragDrop.FilesDropEventHandler FormFilesDropEventHandler;
		event Qurihara.Keyboard.KeyboardDownEventHandler KeyboardDownEventHandler;
		event Qurihara.Keyboard.KeyboardUpEventHandler KeyboardUpEventHandler;
	}
	public abstract class  Mode
	{
		public static Mode CurrentMode=null;
		//protected static System.Collections.Queue queue = new System.Collections.Queue();
		protected static System.Collections.Stack stack = new System.Collections.Stack();
		public static void Pop()
		{
			//if (queue.Count > 0)
			if (stack.Count > 0)
			{
				//Mode m = (Mode)queue.Dequeue();
				Mode m = (Mode)stack.Pop();
				m.ModeChange();
			}
		}

		public void ModeChange()
		{
			if(Mode.CurrentMode != null)
			{
                //CurrentMode.End();
                CurrentMode.Ending();
			}
			CurrentMode = this;
            if (ModeInitializing != null) ModeInitializing(this, new EventArgs());
			Init();
		}
        private void Ending()
        {
            End();
            if (ModeEnded != null) ModeEnded(this, new EventArgs());
        }
		public void Push()
		{
			//queue.Enqueue(this);
			stack.Push(this);
		}
		protected abstract void Init();
		protected abstract void End();

        public event EventHandler ModeInitializing;
        public event EventHandler ModeEnded;
	}
}
